<template>
	<lz-virtual-scroll :windowHeight="systemInfo.windowHeight" ref="lzscroll" @refresherrefresh="refresherrefresh" @scrollBottom="scrollBottom" :status="status">
		<template v-slot:default="{data,index}">
			<list-item :item="data"></list-item>
		</template>
	</lz-virtual-scroll>
</template>

<script>
	let that
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	import listItem from "./listItem.vue";
	export default {
		computed: {
			...mapGetters(['userInfo', 'api'])
		},
		components: {
			listItem
		},
		data() {
			return {
				systemInfo:null,
				page:{
					size:10,
					num:1
				},
				goods: [], //列表数据
				isRequest:false,//当前是否在请求数据
				status:'loading'
			}
		},
		onLoad(e) {
      console.log('printingRecord.onload')
			that = this
			that.signetId = e.id
			//获取系统信息
			that.getSystemInfoSync()
			//使用记录
			that.PrintingRecord()
		},
		methods: {
			//获取系统信息
			getSystemInfoSync(){
				this.systemInfo =uni.getSystemInfoSync()
			},
			refresherrefresh(){
				//console.log('下拉刷新');
				that.$refs.lzscroll.reset()
				that.page.num=1
				that.status ='loading'
				that.isRequest=true
				that.PrintingRecord()
			},
			scrollBottom(){
				//console.log('滚动到底部');
				//判断当前是否在请求数据，如果在请求数据就等待
				if(!that.isRequest){
					that.status ='loading'
					that.isRequest=true
					that.page.num++
					that.PrintingRecord()
				}
			},
			//使用记录
			PrintingRecord() {
				let req = {
					signetId: that.signetId,
					pageSize: that.page.size, //每页的数量
					pageNum: that.page.num, // 当前显示第几页
					page: true,
				}
				//章的接口
				this.$u.post(this.api.GLOBAL_device_sealRecordInfo_getBySignetId, req).then(res => {
					that.isRequest=false
					//console.log(res.data.list[0]);
					if (res.code == 200 && res.data && res.data.list) {
						//如果是量子图片默认显示水印图片
						that.setImageWatermark(res.data.list)
						//虚拟滚动组件传入
						this.$refs.lzscroll.setListData(res.data.list)
						that.status ='loadmore'
					} else {
						that.status ='nomore'
					}
				}).catch((err) => {
					that.isRequest=false
					that.status ='loadmore'
				})
			},
			//如果是量子图片默认显示水印图片
			setImageWatermark(list){
				list.forEach((item)=>{
					if(item.useInfos){
						item.useInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
					if(item.temporaryInfos){
						item.temporaryInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
					if(item.passwordInfos){
						item.passwordInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
					if(item.auditorInfos){
						item.auditorInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
					if(item.replenishInfos){
						item.replenishInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
					if(item.timeoutInfos){
						item.timeoutInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
					if(item.numoutInfos){
						item.numoutInfos.forEach(res=>{
							if(res.enType==3||res.enType==4){
								res.QssfileUrl=res.fileUrl
								res.fileUrl='../../../static/dianxin/shuiyin2.png'
							}
						})
					}
				})
			}
		}
	}
</script>
